package cn.getech.data.development.controller.real;

import cn.getech.data.development.constant.Constant;
import cn.getech.data.development.constant.RunStatus;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.alibaba.excel.annotation.write.style.HeadFontStyle;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;
import java.util.Date;

@Data
@ApiModel(value = "实时任务运维")
public class RealTimeTaskHistoryExcel implements Serializable {

    private static final long serialVersionUID = 1L;

    @ExcelProperty(value = {"项目名称"}, order = 1)
    @HeadFontStyle(color = 0)//red
    @ColumnWidth(16)
    @ApiModelProperty("项目名")
    private String procName;

    @ExcelProperty(value = {"调度队列"}, order = 2)
    @HeadFontStyle(color = 0)//red
    @ColumnWidth(16)
    @ApiModelProperty(value = "调度队列")
    private String queueName;

    @ExcelProperty(value = {"任务类型"}, order = 3)
    @HeadFontStyle(color = 0)//red
    @ColumnWidth(16)
    @ApiModelProperty(value = "任务类型")
    private String taskTypeStr;

    @ExcelProperty(value = {"任务名称"}, order = 4)
    @HeadFontStyle(color = 0)//red
    @ColumnWidth(16)
    @ApiModelProperty("任务名称")
    private String taskName;

    @ExcelProperty(value = {"运行状态"}, order = 5)
    @HeadFontStyle(color = 0)//red
    @ColumnWidth(16)
    @ApiModelProperty("运行状态")
    private String runStateStr;

    @ExcelProperty(value = {"Duration"}, order = 6)
    @HeadFontStyle(color = 0)//red
    @ColumnWidth(16)
    @ApiModelProperty("Duration")
    private String duration;

    @ExcelProperty(value = {"运行时间"}, order = 7)
    @HeadFontStyle(color = 0)//red
    @ColumnWidth(32)
    @ApiModelProperty("运行时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date runTime;

    @ExcelProperty(value = {"创建人"}, order = 8)
    @HeadFontStyle(color = 0)//red
    @ApiModelProperty("创建人名称")
    private String createPerName;

    public RealTimeTaskHistoryExcel(RealTimeTaskHistory history) {
        this.procName = history.getProcName();
        this.queueName = history.getQueueName();
        this.taskTypeStr = Constant.RealTimeTaskType.getNameByCode(history.getTaskType());
        this.taskName = history.getTaskName();
        this.runStateStr = RunStatus.getStatusDesc(history.getRunState());
        this.duration = history.getDuration();
        this.runTime = history.getRunTime();
        this.createPerName =history.getCreatePerName();
    }

    public RealTimeTaskHistoryExcel() {

    }
}
